package com.zhouzi.zhaoyang.adapter.rvadapter;

import android.graphics.Color;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zhouzi.zhaoyang.R;
import com.zhouzi.zhaoyang.bean.GetOrderListBean2;
import com.zhouzi.zhaoyang.util.Calculator;
import com.zhouzi.zhaoyang.util.SPUtils;

import java.util.ArrayList;
import java.util.List;


public class PrintSettingsAdapter extends BaseQuickAdapter<String,BaseViewHolder> {

    public PrintSettingsAdapter(int layoutResId, @Nullable List data) {
        super(layoutResId, data);
    }




    @Override
    protected void convert(BaseViewHolder helper, String item) {



       helper.setText(R.id.cbPrintSettings,item);
        CheckBox cb = helper.getView(R.id.cbPrintSettings);
        Integer value = (Integer) SPUtils.Companion.getInstance().getValue("cbPrintSettings" + helper.getAdapterPosition(), -1);
        if (value == 2){
            cb.setChecked(true);
        }else {
            cb.setChecked(false);

        }

       cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
           @Override
           public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
               if (b){
                       SPUtils.Companion.getInstance().putValue("cbPrintSettings"+helper.getAdapterPosition(),2);
               }else {
                   SPUtils.Companion.getInstance().putValue("cbPrintSettings"+helper.getAdapterPosition(),1);
               }
           }
       });
    }
}
